package config

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConf struct {
	Mysql struct {
		User     string
		Password string
		Host     string
		Port     int
		Database string
	}
	Redis struct {
		Addr     string
		Password string
		DB       int
	}
}

var Conf AppConf

func ConfInit() {
	viper.SetConfigFile("./config/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println("配置文件读取失败")
	}
	err = viper.Unmarshal(&Conf)
	if err != nil {
		fmt.Println("配置文件解析失败")
	}
	fmt.Println(&Conf)
}
